package org.springblade.tms.module.sap.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springblade.core.log.annotation.ApiLog;
import org.springblade.core.secure.annotation.PreAuth;
import org.springblade.core.tool.api.R;
import org.springblade.tms.global.constant.AuthConstant;
import org.springblade.tms.module.sap.base.SapService;
import org.springblade.tms.module.sap.dto.*;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @author: yr
 * @className: SapController
 * @createDate: 2022/3/7
 * @description: sap接口
 */
@RestController
@RequestMapping("sap")
@Api(value = "sap", tags = "sap")
@Validated
public class SapController {
	@Resource
	private SapService sapService;

	/**
	 * @param carrierList
	 * @return
	 * @Desc 承运商基本信息接口
	 * @author: yr
	 * @createDate: 2022/3/7
	 */
	@ApiLog("承运商基本信息")
	@ApiOperationSupport(order = 1)
	@ApiOperation(value = "承运商基本信息", notes = "传入carrier")
	@PostMapping("/carrier")
	@PreAuth(AuthConstant.AUTH_SAP)
	public R carrierBasicInformation(@RequestBody @Valid List<Carrier> carrierList) {
		return sapService.carrierBasicInformation(carrierList);
	}

	/**
	 * @param demandListDtoList
	 * @return
	 * @Desc 需求单数据接口
	 * @author: yr
	 * @createDate: 2022/3/7
	 */
	@ApiLog("需求单数据接口")
	@ApiOperationSupport(order = 2)
	@ApiOperation(value = "需求单数据接口", notes = "传入demandListDto")
	@PostMapping("/requestOrderData")
	@PreAuth(AuthConstant.AUTH_SAP)
	public R requestOrderData(@RequestBody  @Valid List<DemandListDto> demandListDtoList) {
		return sapService.requestOrderData(demandListDtoList);
	}

	/**
	 * @param updateWaybillDTOS
	 * @return
	 * @Desc 运单更新接口
	 * @author: yr
	 * @createDate: 2022/3/7
	 */
	@ApiLog("运单更新接口")
	@ApiOperationSupport(order = 3)
	@ApiOperation(value = "运单更新接口", notes = "传入demandListDto")
	@PostMapping("/updateWaybill")
	@PreAuth(AuthConstant.AUTH_SAP)
	public R UpdateWaybill(@RequestBody  @Valid UpdateWaybillDTO updateWaybillDTOS) {
		return sapService.waybillUpdate(updateWaybillDTOS);
	}


	/**
	 * @param sapEnquiryVo
	 * @return
	 * @Desc 询价单推送
	 * @author: yr
	 * @createDate: 2022/3/7
	 */
	@ApiLog("询价单推送接口")
	@ApiOperationSupport(order = 4)
	@ApiOperation(value = "询价单推送接口", notes = "传入sapEnquiryVo")
	@PostMapping("/inquiryFormPush")
	@PreAuth(AuthConstant.AUTH_SAP)
	public R inquiryFormPush(@RequestBody  @Valid SapEnquiryVo sapEnquiryVo) {
		return sapService.inquiryFormPush(sapEnquiryVo);
	}
}
